<?php
	require_once("../classes/EntryList.php");
	require_once("../classes/Database.php");
	
	session_start();

	$find = "%".$_POST["find"]."%";
	
	$db = new Database("localhost", "root", "");
	$db->connect("emprego");
	$db->executeQuery("SELECT u.nome, c.id, cat.name, c.description
						FROM curriculum c, users u, category cat
						WHERE c.id=u.id AND c.category=cat.id AND u.nome LIKE '$find'");
	
	if($line = $db->getResultLine(MYSQL_ASSOC)){
		$entry = new EntryList("entry");
		do{
			$entry->openEntry();
			$entry->addLinkTitle("viewCV.php?candidate=".$line["id"], "Ver Curriculum Vitae");
			$entry->addEntry("Nome:", $line["nome"]);
			$entry->addEntry("Categoria:", $line["name"]);
			$entry->addEntry("Descri&ccedil&atildeo:", $line["description"]);
			$entry->closeEntry();
			$entry->addHtmlCode("</br></br>");
		}while($line = $db->getResultLine(MYSQL_ASSOC));
	}

	$_SESSION["entry"] = $entry;
	header("Location: ../findCV.php");
?>